using System;
using System.Collections.Generic;
using System.Text;
using QLHXNK.DataAccess;
using System.Data;

namespace QLHXNK.BusinessLogic
{
    class ImportNoteDetail
    {
        private int importNoteDetailID;
        private int importNoteID;
        private int itemID;
        private int quantity;
        private double fobUSD;
        private double fobEUR;
        private double cifUSD;
        private double cifEUR;
        private double KRfee;
        private double HKfee;
        private double ITALYfee;
        private double TLfee;
        private double otherCountryfee;
        private double UTfee;
        private double VATfee;
        private double TAXfee;
        private double otherfee;
        private double Net1;
        private double Net2;
        private double sellPrice;
        private double profit1;
        private double profit2;

        #region Properties

        public int ID{ get { return importNoteDetailID; } }

        public int ImportNote
        {
            get { return importNoteID; }
            set { importNoteID = value; }
        }

        public int Item
        {
            get { return itemID; }
            set { itemID = value; }
        }

        public int Quantity
        {
            get { return quantity; }
            set { quantity = value; }
        }

        public double FOBUSD
        {
            get { return fobUSD; }
            set { fobUSD = value; }
        }
        public double FOBEUR
        {
            get { return fobEUR; }
            set { fobEUR = value; }
        }
        public double CIFUSD
        {
            get { return cifUSD; }
            set { cifUSD = value; }
        }
        public double CIFEUR
        {
            get { return cifEUR; }
            set { cifEUR = value; }
        }
        public double KRFEE
        {
            get { return KRfee; }
            set { KRfee = value; }
        }
        public double HKFEE
        {
            get { return HKfee; }
            set { HKfee = value; }
        }
        public double ITALYFEE
        {
            get { return ITALYfee; }
            set { ITALYfee = value; }
        }
        public double TLFEE
        {
            get { return TLfee; }
            set { TLfee = value; }
        }
        public double OTHERCOUNTRYFEE
        {
            get { return otherCountryfee; }
            set { otherCountryfee = value; }
        }
        public double UTFEE
        {
            get { return UTfee; }
            set { UTfee = value; }
        }
        public double VATFEE
        {
            get { return VATfee; }
            set { VATfee = value; }
        }
        public double TAXFEE
        {
            get { return TAXfee; }
            set { TAXfee = value; }
        }
        public double OTHERFEE
        {
            get { return otherfee; }
            set { otherfee = value; }
        }
        public double NET1
        {
            get { return Net1; }
            set { Net1=value; }
        }
        public double NET2
        {
            get { return Net2; }
            set { Net2 = value; }
        }
        public double SellingPrice
        {
            get { return sellPrice; }
            set { sellPrice = value; }
        }
        public double Profit1
        {
            get { return profit1; }
            set { profit1 = value; }
        }
        public double Profit2
        {
            get { return profit2; }
            set { profit2 = value; }
        }
        #endregion

        public ImportNoteDetail(int importNoteDetailID, int importNoteID, int itemID, int quantity, double fobUSD, double fobEUR, double cifUSD, double cifEUR, double KRfee, double HKfee, double ITALYfee, double TLfee, double otherCountryfee, double UTfee, double VATfee, double TAXfee, double otherfee, double Net1, double Net2, double sellPrice, double profit1, double profit2)
        {
            this.importNoteDetailID = importNoteDetailID;
            this.importNoteID = importNoteID;
            this.itemID = itemID;
            this.quantity = quantity;
            this.fobUSD = fobUSD;
            this.fobEUR = fobEUR;
            this.cifUSD = cifUSD;
            this.cifEUR = cifEUR;
            this.KRfee = KRfee;
            this.HKfee = HKfee;
            this.ITALYfee = ITALYfee;
            this.TLfee = TLfee;
            this.otherCountryfee = otherCountryfee;
            this.UTfee = UTfee;
            this.VATfee = VATfee;
            this.otherfee = otherfee;
            this.Net1 = Net1;
            this.Net2 = Net2;
            this.sellPrice = sellPrice;
            this.profit1 = profit1; 
            this.profit2 = profit2;
        }

        #region ----------------------------------------Lấy thông tin hàng-----------------------------------------

        public static DataTable GetImportNoteDetailByImportNote(int importNoteID)
        {
            try
            {
                return ImportNoteDetailData.GetImportNoteDetail(importNoteID,"");
            }
            catch
            {
                return null;
            }
        }
        public static DataTable GetImportNoteDetailByImportNoteAndItem(int importNoteID, String itemName)
        {
            try
            {
                return ImportNoteDetailData.GetImportNoteDetail(importNoteID, itemName);
            }
            catch
            {
                return null;
            }
        }
        
        #endregion

        #region ------------------------------------------Thêm, xoá, sửa-------------------------------------------

        public static ImportNoteDetail CreateImportNoteDetail(int importNoteID, int itemID, int quantity, double fobUSD, double fobEUR, double cifUSD, double cifEUR, double KRfee, double HKfee, double ITALYfee, double TLfee, double otherCountryfee, double UTfee, double VATfee, double TAXfee, double otherfee, double NET1, double NET2, double sellPrice, double profit1, double profit2)
        {
            try
            {
                int id = ImportNoteDetailData.CreateImportNoteDetail(importNoteID, itemID, quantity, fobUSD, fobEUR, cifUSD, cifEUR, KRfee, HKfee, ITALYfee, TLfee, otherCountryfee, UTfee, VATfee, TAXfee, otherfee, NET1, NET2, sellPrice, profit1, profit2);
                ImportNoteDetail importNoteDetail = null;
                if (id != 0)
                    importNoteDetail = new ImportNoteDetail(id, importNoteID, itemID, quantity, fobUSD, fobEUR, cifUSD, cifEUR, KRfee, HKfee, ITALYfee, TLfee, otherCountryfee, UTfee, VATfee, TAXfee, otherfee, NET1, NET2, sellPrice, profit1, profit2);
                return importNoteDetail;
            }
            catch
            {
                return null;
            }
        }

        public int DeleteImportNoteDetail()
        {
            try
            {
                return ImportNoteDetailData.DeleteImportNoteDetail(this.ID); ;
            }
            catch
            {
                return 0;
            }
        }

        public int Save()
        {
            try
            {
                return ImportNoteDetailData.UpdateImportNoteDetail(this.importNoteDetailID,this.itemID,this.quantity,this.fobUSD,this.fobEUR,this.cifUSD,this.cifEUR,this.KRfee,this.HKfee,this.ITALYfee,this.TLfee,this.otherCountryfee,this.UTfee,this.VATfee,this.TAXfee,this.otherfee,this.Net1,this.Net2,this.sellPrice,this.profit1,this.profit2);
            }
            catch
            {
                return 0;
            }
        }

        public int UpdateImportNote(int itemID, int quantity, double fobUSD, double fobEUR, double cifUSD, double cifEUR, double KRfee, double HKfee, double ITALYfee, double TLfee, double otherCountryfee, double UTfee, double VATfee, double TAXfee, double otherfee, double Net1, double Net2, double sellPrice, double profit1, double profit2)
        {
            try
            {
                this.itemID = itemID;
                this.quantity = quantity;
                this.fobUSD = fobUSD;
                this.fobEUR = fobEUR;
                this.cifUSD = cifUSD;
                this.cifEUR = cifEUR;
                this.KRfee = KRfee;
                this.HKfee = HKfee;
                this.ITALYfee = ITALYfee;
                this.TLfee = TLfee;
                this.otherCountryfee = otherCountryfee;
                this.UTfee = UTfee;
                this.VATfee = VATfee;
                this.otherfee = otherfee;
                this.Net1 = Net1;
                this.Net2 = Net2;
                this.sellPrice = sellPrice;
                this.profit1 = profit1;
                this.profit2 = profit2;
                return Save();
            }
            catch
            {
                return 0;
            }
        }

        #endregion
    }
}
